package com.cmfi.domain.PlcEntity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.cmfi.domain.SubscribeCallBack;

@Component
public class PlcSubscribeCallBack implements SubscribeCallBack {

	static Logger log = LoggerFactory.getLogger(PlcSubscribeCallBack.class);
	
	@Override
	public void call(String identifier, String value) {
		log.info("[PlcSubscribeCallBack][call] start,identifier:{},value:{}", identifier, value);
		if (identifier == null || value == null) {
			log.info("[PlcSubscribeCallBack][call] param is null");
			return;
		}
		switch (identifier) {
			case Identifier.WORK_ORDER_RELEASE_FOR_WORKPIECE_1://第一个为例子，可以往后顺序添加其他订阅点位
				workOrderReaseForWorkpiece1( identifier,  value);
				break;
				
			default:
				log.info("[PlcSubscribeCallBack][call] default");
				break;
		}
	}
	
	/**
	 * PLC请求下发工单，例子
	 * @param identifier PLC点位的Identifier
	 * @param value 点位值
	 */
	private void workOrderReaseForWorkpiece1(String identifier, String value) {
		// TODO Auto-generated method stub
		log.info("[PlcSubscribeCallBack][workOrderReaseForWorkpiece1] identifier:{},value:{}", identifier, value);
	}

}
